﻿using System;
using System.Text.RegularExpressions;
using System.Windows.Forms;

namespace XFSale.UI
{
    public partial class WinPassword : WinBase
    {
        public string Password
        {
            get { return TxtPassword.Text; }
        }

        public WinPassword()
        {
            InitializeComponent();
        }

        private void WinPasswod_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (DialogResult == DialogResult.Retry)
            {
                e.Cancel = true;
            }
        }

        private void BtnOk_Click(object sender, EventArgs e)
        {
            if (!Regex.IsMatch(TxtPassword.Text, @"^\d{6}$"))
            {
                MessageBox.Show("请输入6位数字", "输入错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                DialogResult = DialogResult.Retry;
                return;
            }

            if (TxtPassword.Text != TxtPassword2.Text)
            {
                MessageBox.Show("密码验证错误", "输入错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                TxtPassword.Text = string.Empty;
                TxtPassword2.Text = string.Empty;
                DialogResult = DialogResult.Retry;
                return;
            }
        }
    }
}
